//
//  FQMineHeaderSectionController.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/8/25.
//

import UIKit

class FQMineHeaderSectionController: BaseListSectionController {
    var model : FQMineHeaderModel!
    
    override func sizeForItem(at index: Int) -> CGSize {
        CGSize(width: SCREEN_WIDTH, height: PreferredValueForNotchedDevice(notchedDevice: 245, otherDevice: 220))
    }
    
    override func cellForItem(at index: Int) -> UICollectionViewCell {
        let cell = dequeueReusableCell(cellType: FQMineHeaderCollectionViewCell.self, index: index)
        cell.model = model
        cell.headerBlock = { 
            if BaseUserModel.checkUser(needPushLogin: true, withoutTip: true) {

            }
        }
        cell.buttonBlock = { [unowned self] index in
            if !BaseUserModel.checkUser(needPushLogin: true) {
                return
            }
            switch index - 10 {
            case 0, 1, 2:
                let vc = FQBorrowListViewController()
                vc.index = index - 10
                self.viewController?.navigationController?.qmui_pushViewController(vc, animated: true)
            default:
                break
            }
        }
        return cell
    }
    
    override func didUpdate(to object: Any) {
        model = object as? FQMineHeaderModel
    }
}
